#include <bits/stdc++.h>

using namespace std;
class Solution
{
public:
    long long maxKelements(vector<int> &nums, int k)
    {
        long long ans;
        priority_queue<int> q;
        for (int i = 0; i < nums.size(); ++i)
        {
            q.push(nums[i]);
        }
        while (k--)
        {
            int num = q.top();
            q.pop();
            ans += num;
            q.push(ceil(num / 3));
        }
        return ans;
    }
};